﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using DanTriNews.Src.Helper;

namespace DanTriNews.Src
{
    public partial class Selectcategory : PhoneApplicationPage
    {
        public Selectcategory()
        {
            InitializeComponent();
            llsCategory.ItemsSource = App.ViewModel.Categories;
        }

        private void StackPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            TextBlock tblId = ((StackPanel)sender).FindName("tblId") as TextBlock;
            NavigationService.Navigate(new Uri("/MainPage.xaml?CategoryId="+tblId.Text, UriKind.Relative));
        }
        protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
        {
            PhoneApplicationPage phoneApplicationPage = (PhoneApplicationPage)(((PhoneApplicationFrame)Application.Current.RootVisual)).Content;
            TransitionHelper.excuteTransition(phoneApplicationPage);
            base.OnNavigatingFrom(e);
        }
            protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            int categoryId = int.Parse(NavigationContext.QueryString["CategoryId"]);
            NavigationService.Navigate(new Uri("/MainPage.xaml?CategoryId=" + categoryId, UriKind.Relative));
            base.OnBackKeyPress(e);
        }
    }
}